import Vue from 'vue'
import Router from 'vue-router'
// 获取原型对象上的push函数
const originalPush = Router.prototype.push
// 修改原型对象中的push方法
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err)
}
Vue.use(Router)
export const routes = [
    {
        path: '/',
        redirect: () => {
            return '/guide'
        },
        hidden: true,
    },
    {
        path: '/guide',
        component: () => import('../view/guide/index'),
        redirect: 'guide/install',
        children: [
            {
                path: 'install',
                name: 'install',
                component: () => import('../view/guide/install'),
            },
            {
                path: 'start',
                name: 'start',
                component: () => import('../view/guide/start'),
            },
            {
                path: 'version',
                name: 'version',
                component: () => import('../view/guide/version'),
            },
            {
                path: 'npm',
                name: 'npm',
                component: () => import('../view/guide/npm'),
            },
        ],
    },
    {
        path: '/sdnui',
        component: () => import('../view/baseCpns/index'),
        hidden: true,
        redirect: 'sdnui/button',
        children: [
            {
                path: 'button',
                name: 'button',
                component: () => import('../view/baseCpns/button/index')
            },
            {
                path: 'tag',
                name: 'tag',
                component: () => import('../view/baseCpns/tag/index')
            },
            {
                path: 'alert',
                name: 'alert',
                component: () => import('../view/baseCpns/alert/index')
            },
            {
                path: 'empty',
                name: 'empty',
                component: () => import('../view/baseCpns/empty/index')
            }, {
                path: 'checkbox',
                name: 'checkbox',
                component: () => import('../view/baseCpns/checkbox')
            }, {
                path: 'colorPicker',
                name: 'colorPicker',
                component: () => import('../view/baseCpns/colorPicker')
            },
            {
                path: 'cascader',
                nameL: 'cascader',
                component: () => import('../view/baseCpns/cascader')
            },
            {
                path: 'timePicker',
                nameL: 'timePicker',
                component: () => import('../view/baseCpns/timePicker')
            },
            {
                path: 'radio',
                nameL: 'radio',
                component: () => import('../view/baseCpns/radio')
            },
            {
                path: 'switch',
                nameL: 'switch',
                component: () => import('../view/baseCpns/switch')
            },
            {
                path: 'slider',
                nameL: 'slider',
                component: () => import('../view/baseCpns/slider')
            },
            {
                path: 'select',
                nameL: 'select',
                component: () => import('../view/baseCpns/select')
            },
            {
                path: 'datePicker',
                nameL: 'datePicker',
                component: () => import('../view/baseCpns/datePicker')
            },
            {
                path: 'progress',
                name: 'progress',
                component: () => import('../view/baseCpns/progress/index')
            },
            {
                path: 'form',
                name: 'form',
                component: () => import('../view/baseCpns/form/index')
            },
            {
                path: 'upload',
                name: 'upload',
                component: () => import('../view/baseCpns/upload/index')
            },
            {
                path: 'input',
                name: 'input',
                component: () => import('../view/baseCpns/input/index')
            },
            {
                path: 'inputNumber',
                name: 'inputNumber',
                component: () => import('../view/baseCpns/inputNumber/index')
            },
            {
                path: 'link',
                name: 'link',
                component: () => import('../view/baseCpns/link/index')
            },
            {
                path: 'menu',
                name: 'menu',
                component: () => import('../view/baseCpns/menu/index')
            },
            {
                path: 'tabs',
                name: 'tabs',
                component: () => import('../view/baseCpns/tabs/index')
            },
            {
                path: 'breadcrumb',
                name: 'breadcrumb',
                component: () => import('../view/baseCpns/breadcrumb/index')
            },
            {
                path: 'steps',
                name: 'steps',
                component: () => import('../view/baseCpns/steps/index')
            },
            {
                path: 'dialog',
                name: 'dialog',
                component: () => import('../view/baseCpns/dialog/index')
            },
            {
                path: 'tooltip',
                name: 'tooltip',
                component: () => import('../view/baseCpns/tooltip/index')
            },
            {
                path: 'pagination',
                name: 'pagination',
                component: () => import('../view/baseCpns/pagination/index')
            },
            {
                path: 'rate',
                name: 'rate',
                component: () => import('../view/baseCpns/rate/index')
            },
            {
                path: 'multiFunMessage',
                name: 'multiFunMessage',
                component: () => import('../view/baseCpns/multiFunMessage/index')
            }
        ],
    },
    {
        path: '/sdnuiPro',
        component: () => import('../view/proCpns/index'),
    },
    {
        path: '/common',
        component: () => import('../view/common/index'),
    },
    {
        path: '/more',
        component: () => import('../view/more/index'),
    }
]

export default new Router({
    routes,
})
